package ast;

import java.util.ArrayList;

import util.Pair;

public class DQCSystem {

	private ArrayList<Procedure> procedures;
	private Network network;
	private ArrayList<Constant> clsys;
	private ArrayList<Pair<String, String>> afPairs;
	// ignore the environment list since no analysis needs it 
	private ArrayList<Function> functions;
	
	public DQCSystem(
			ArrayList<Procedure> ps, 
			Network n, 
			ArrayList<Constant> cl,
			ArrayList<Pair<String, String>> afs,
			ArrayList<Function> funcs)
	{
		procedures = ps;
		network = n;
		clsys = cl;
		afPairs = afs;
		functions = funcs;
	}
	
	public ArrayList<Procedure> getProcedures() {
		return procedures;
	}

	public void setProcedures(ArrayList<Procedure> procedures) {
		this.procedures = procedures;
	}

	public Network getNetwork() {
		return network;
	}

	public void setNetwork(Network network) {
		this.network = network;
	}

	public ArrayList<Constant> getClsys() {
		return clsys;
	}

	public void setClsys(ArrayList<Constant> clsys) {
		this.clsys = clsys;
	}

	public ArrayList<Pair<String, String>> getAfPairs() {
		return afPairs;
	}

	public void setAfPairs(ArrayList<Pair<String, String>> afPairs) {
		this.afPairs = afPairs;
	}

	public ArrayList<Function> getFunctions() {
		return functions;
	}

	public String toString(int indent)
	{
		String res = "";
		res += "define\n";
		for(Procedure proc : procedures)
		{
			res += proc.toString(0) + "\n";
		}
		res += "in\n";
		res += network.toString(0) + "\n";
		res += "using" + "(";
		for(int i = 0; i < clsys.size(); i++) {
			Constant cst = clsys.get(i);
			if (cst instanceof DataConstant)
				res += ((DataConstant) cst).toString();
			else
				res += ((ChannelConstant) cst).toString();
			
			if (i != clsys.size() - 1)
				res += ", ";
		}
		res += "), (...)\n";
		res += "with ";
		for (int i = 0; i < afPairs.size(); i++) {
			res += afPairs.get(i).getFst() + ">" + afPairs.get(i).getSnd();
			if (i < afPairs.size() - 1) 
				res += ", ";
		}
	
		return res;
	}
}
